﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace Kingdom_of_the_Dragon
{
    class Enemy
    {
        public Texture2D texture;
        public Vector2 position;
        public Vector2 posResult;

        public float radiansResult;
        public float angleResult;
        private int speed;
        public int vida = 100;

        public Enemy(Texture2D texture, Vector2 position)
        {
            this.position = position;
            this.texture = texture;
            this.speed = 5;
        }

        public void Draw(SpriteBatch spriteBratch, Vector2 cameraorigem)
        {
            spriteBratch.Begin();
            spriteBratch.Draw(texture, new Rectangle((int)cameraorigem.X + (int)position.X, (int)cameraorigem.Y + (int)position.Y,
                (int)texture.Width, (int)texture.Height),
                new Rectangle(0, 0, texture.Width, texture.Height),
                Color.Green,radiansResult,
                new Vector2(texture.Width / 2, texture.Height / 2),
                SpriteEffects.FlipVertically, 0f);
            spriteBratch.End();
        }

        public void Update(Vector2 position_ship)
        {
            posResult = position_ship - position ;

            radiansResult = (float)Math.Atan2(posResult.X, posResult.Y);
            radiansResult = -radiansResult;
            angleResult = MathHelper.ToDegrees(radiansResult);
        }
    }
}
